/**  
 * All rights Reserved, Designed By <a href="www.itttq.com" target="_blank">www.itttq.com</a>
 * @date:   2017-07-21 11:42:21
 * @Copyright: 2017 <a href="www.itttq.com" target="_blank">www.itttq.com</a> Inc. All rights reserved. 
 */
package com.itttq.gshop.pbpm.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Lang;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.UpdateProvider;

import com.itttq.gshop.domain.po.WareCatBrandPo;
import com.itttq.gshop.domain.to.CatBrandTo;
import com.itttq.gshop.pbpm.cmpt.mybatis.CustomInLanguage;
import com.itttq.gshop.pbpm.provider.WareCatBrandSqlProvider;

@Mapper
public interface IWareCatBrandMapper {
	/**
	 * 新增WareCatBrandPo对象
	 * 
	 * @param WareCatBrandPo
	 * @Author 迷蝶
	 * @return Integer
	 */
	@InsertProvider(type=WareCatBrandSqlProvider.class,  method="addWareCatBrand") 
	public Integer addWareCatBrand(WareCatBrandPo wareCatBrand);

	/**
	 * 更新WareCatBrandPo对象
	 * 
	 * @param wareCatBrandPo
	 * @Author 迷蝶
	 * @return Integer
	 */
	@UpdateProvider(type=WareCatBrandSqlProvider.class,  method="updateWareCatBrand") 
	public Integer updateWareCatBrand(WareCatBrandPo wareCatBrand);
	
	/**
	 * 根据ID删除WareCatBrandPo对象
	 * 
	 * @param id
	 * @Author 迷蝶
	 * @return Integer
	 */
	@DeleteProvider(type=WareCatBrandSqlProvider.class,  method="delWareCatBrand") 
	public Integer delWareCatBrandById(Integer id);

	/**
	 * 根据IDS删除WareCatBrandPo对象
	 * 
	 * @param ids
	 * @Author 迷蝶
	 * @return List<WareCatBrandPo>
	 */
	@Lang(CustomInLanguage.class)
	@Delete("DELETE FROM ware_cat_brand WHERE id IN (#{ids})")
	public Integer delWareCatBrandByIds(@Param("ids") List<Integer> ids);
	
	/**
	 * 根据条件查找WareCatBrandPo对象，默认根据ID降序
	 * 
	 * @param wareCatBrandPo
	 * @Author 迷蝶
	 * @return List<WareCatBrandPo>
	 */
	@SelectProvider(type=WareCatBrandSqlProvider.class,  method="findWareCatBrands") 
	public List<WareCatBrandPo> findWareCatBrands(WareCatBrandPo wareCatBrand);
	
	/**
	 * 根据条件查找记录总数
	 * 
	 * @param wareCatBrandPo
	 * @Author 迷蝶
	 * @return Integer
	 */
	@SelectProvider(type=WareCatBrandSqlProvider.class,  method="findWareCatBrandCount") 
	public Integer findWareCatBrandCount(WareCatBrandPo wareCatBrand);
	
	/**
	 * 根据ID查找WareCatBrandPo对象
	 * 
	 * @param id
	 * @Author 迷蝶
	 * @return WareCatBrandPo
	 */
	@SelectProvider(type=WareCatBrandSqlProvider.class,  method="findWareCatBrandById") 
	public WareCatBrandPo findWareCatBrandById(Integer id);

	/**
	 * 查询可用的品牌分类数据，并根据显示顺序降序
	 * 
	 * @param id
	 * @Author 迷蝶
	 * @return WareCatBrandPo
	 */
	@Select("select cb.cat_id,cb.cat_name,cb.brand_id,cb.brand_name,b.logo from ware_brand b, ware_cat_brand cb where cb.`status`=1 and b.`status`=1 and b.id=cb.brand_id order by b.display_order desc") 
	public List<CatBrandTo> findCatBrands();
	
}